const { describe, it } = require("node:test");
const assert = require("node:assert");

const { chunk, uniq, compact, sum } = require("../lib/array.js");

describe("array.js", function () {
  it("chunk", function () {
    assert.deepStrictEqual(chunk([1, 2, 3, 4, 5, 6, 7, 8, 9, 0], 3), [
      [1, 2, 3],
      [4, 5, 6],
      [7, 8, 9],
      [0],
    ]);
  });
  it("uniq", function () {
    assert.deepStrictEqual(uniq([1, 2, 3, 3, "4", 4], Number), [1, 2, 3, "4"]);
    assert.deepStrictEqual(uniq([1, 2, 3, 3, 4, "4"], Number), [1, 2, 3, 4]);
  });
  it("compact", function () {
    assert.deepStrictEqual(compact([1, 2, 3, 0, false, ""]), [1, 2, 3]);
  });
  it("sum", function () {
    assert.equal(sum([4, 2, 8, 6]), 20);
  });
});
